Skip to content

Conversation

@yo-ga
Copy link
Contributor

@yo-ga yo-ga commented Dec 10, 2024

Description

  • Support CloudFormation the following intrinsic functions in environment variable
    • Fn::Join
    • !Join
    • Fn::Sub
    • !Sub

Motivation and Context

How Has This Been Tested?

example yaml:

service: aws-node-project
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x
  region: ap-northeast-1
  stage: dev
  environment:
      getKeyARN:
        Fn::Join:
          - ':'
          - - 'arn:aws:lambda'
            - ${self:provider.region}
            - Ref: 'AWS::AccountId'
            - 'function'
            - ${self:service}-${self:provider.stage}-getKey
      qa: 12345

functions:
  function1:
    handler: index.handler
    environment:
      getKeyARN:
        Fn::Join:
          - ':'
          - - 'arn:aws:lambda'
            - ${self:provider.region}
            - Ref: 'AWS::AccountId'
            - 'function'
            - ${self:service}-${self:provider.stage}-getKey
      qa: 12345

plugins:
  - serverless-offline

eample js:

module.exports.handler = async (event) => {
  console.log("test")
  console.log(process.env)
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        message: 'Go Serverless v3.0! Your function executed successfully!',
        input: event,
      },
      null,
      2
    ),
  };
};

@DorianMazur DorianMazur reopened this Jan 17, 2025
@DorianMazur DorianMazur merged commit d785b78 into dherault:master Mar 1, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[object Object] as environment variable when using CF functions Using Fn::Join resolves to [Object Object]

2 participants